<!DOCTYPE html>
<html lang="en">
<head>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="../static/css/style1.css" rel="stylesheet" type="text/css" />
        <link rel="icon" href="../static/images/logo.ico" type="image/x-icon"/>
        <script src="../static/js/jquery.js"></script>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css"
              integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
                integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js"
                integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

        <title>我的选课</title>
    </head>
</head>
<body>
<div class="wapper_box">
        <div class="header_box"></div>
        <div class="header_box1">
            <div class="header_box2">
                <a class="logo_box" href="{{ url_for('index') }}">
                    <img src="../static/images/logo1.jpeg"/></a>
                <ul class="nav_box">
                    <li class="nav_1"><a class="nav_but" href="{{ url_for('personal_information') }}">个人中心</a></li>
                    <li class="nav_1"><a class="nav_but" href="{{ url_for('news_center') }}">课程论坛</a></li>
                    <li class="nav_1"><a class="nav_but" href="{{ url_for('stuCourses') }}">学生选课</a></li>
                    <li class="nav_1"><a class="nav_but" href= "{{ url_for('index') }}">首页</a></li>
                </ul>
            </div>
        </div>
        <div class="content_box1">
            <div class="content_box2">
                <div class="menu_box">
                    <p class="menu_box_title">学生选课</p>
                    <ul class="menu_box1">
                        <li><a href="{{ url_for('stuCourses') }}">选课大厅</a></li>
                        <li><a href="{{ url_for('elective_record') }}">我的选课</a></li>
                    </ul>
                </div>
                <div class="content_boxL">
                    <div class="content_boxL_nav">
                        <p class="content_boxL_nav_title">学生选课</p >
                        <div class="content_boxL_nav_R">
                            <a href="{{ url_for('index') }}">首页></a>
                            <a href="{{ url_for('stuCourses') }}">学生选课 ></a>
                            <a href="{{ url_for('stuCourses') }}"> 选课大厅</a>
                        </div>
                    </div>
                    <table class="table">
                      <thead>
                        <tr>
                          <th scope="col">课程名称</th>
                          <th scope="col">详细信息</th>
                          <th scope="col">操作</th>
                        </tr>
                      </thead>
                      <tbody>
                       {% for message in result %}
                        <tr>
                          <td>{{ message.name }}</td>
                          <td>{{ message.info }}</td>
                          <td><button type="submit" class="btn btn-warning btn-sm" onclick="chossse_course({{ message.id }})" >取消选课</button></td>
                        </tr>
                        {% endfor %}
                      </tbody>
                    </table>
                <nav aria-label="Page navigation example">
                  <ul class="pagination" style="padding-left: 360px">
                    <li class="page-item">
                      <a class="page-link" href="#" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                      </a>
                    </li>
                    <li class="page-item"><a class="page-link" href="#">1</a></li>
                    <li class="page-item"><a class="page-link" href="#">2</a></li>
                    <li class="page-item"><a class="page-link" href="#">3</a></li>
                    <li class="page-item">
                      <a class="page-link" href="#" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                      </a>
                    </li>
                  </ul>
                </nav>
                </div>
            </div>
        </div>
</body>
<script >
    function chossse_course(id1) {
        $.ajax({
            url:'{{ url_for("elective_record_delete") }}?id='+id1, // 地址
            dataType:'json', // 数据类型
            type:'delete', // 类型
            timeout:2000, // 超时
            success: function (data, status) { // 请求成功
                if (data.result=="success") {
                    alert("取消成功");
                    window.location.reload();
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) { // 失败/超时
                if (textStatus==='timeout') {
                    alert('请求超时');
                    setTimeout(function() {
                        alert('重新请求');
                    },2000);
                }
            }
        });
    }
</script>
</html>